package com.cg.mapper;

import com.cg.dto.AiTalkDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;

import java.util.Date;
import java.util.List;

@Mapper
public interface AiTalkMapper {

    int insertBatch(@Param("list") List<AiTalkDTO> list);

    int insertOne(AiTalkDTO dto);

    List<AiTalkDTO> selectByUserId(@Param("userId") Long userId,
                                   @Param("limit") Integer limit);

    @Delete("DELETE FROM ai_talk WHERE user_id = #{userId}")
    int deleteByUserId(@Param("userId") Long userId);

    @Delete("DELETE FROM ai_talk WHERE user_id = #{userId} AND create_time < #{beforeTime}")
    int deleteBefore(@Param("userId") Long userId, @Param("beforeTime") Date beforeTime);
}

